<page-header [autoTitle]="false"></page-header>
<nz-card>
  <app-market-salesman-role-setting [role]="role" *ngIf="role != 1"></app-market-salesman-role-setting>
  <section class="search-section">
    <input nz-input placeholder="姓名、手机" [(ngModel)]="keyword" class="search-item"/>
    <nz-select [(ngModel)]="districtId" [nzPlaceHolder]="'所属运营中心'" class="search-item" [nzAllowClear]="true">
      <nz-option
        *ngFor="let option of districtOption"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <nz-select *ngIf="role == 3 || role == 4" [(ngModel)]="type" [nzPlaceHolder]="(role == 3?'门店':'代理')+'类别'" class="search-item" [nzAllowClear]="true">
      <nz-option
        *ngFor="let option of salesManTypeOption"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()" class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
    <button nz-button [nzType]="'primary'" *ngIf="role === 1" (click)="editEntity({id:null})" class="search-add-right">
      <i class="anticon anticon-plus"></i><span>添加</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th><span>姓名</span></th>
      <th nz-th><span>手机</span></th>
      <th nz-th *ngIf="role == 3"><span>门店名称</span></th>
      <th nz-th *ngIf="role == 3"><span>门店类别</span></th>
      <th nz-th *ngIf="role == 4"><span>代理名称</span></th>
      <th nz-th *ngIf="role == 4"><span>代理类别</span></th>
      <th nz-th><span>身份证号</span></th>
      <th nz-th><span>运营中心</span></th>
      <th nz-th><span>加入时间</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td>{{data.name}}</td>
      <td>{{data.phone}}</td>
      <td *ngIf="role == 3 || role == 4">{{data.shopName}}</td>
      <td *ngIf="role == 3 || role == 4">{{data.typeId|dicsNamePipe:salesManTypeOption:"id":"name"}}</td>
      <td>{{data.idNumber}}</td>
      <td>{{data.districtId|dicsNamePipe:districtOption:"id":"name"}}</td>
      <td>{{data.createdAt}}</td>
      <td>
        <a href="javascript:void (0);" routerLink="/salesman/list/{{role}}/detail" [queryParams]="{id: data.id}">查看详情</a>
        <nz-divider nzType="vertical"></nz-divider>
        <a href="javascript:void (0);" (click)="setPassword(data)">重置密码</a>
        <!--<nz-divider nzType="vertical"></nz-divider>
        <nz-popconfirm [nzTitle]="'确定要删除这条数据吗？'" (nzOnConfirm)="delete(data)">
          <a nz-popconfirm>删除</a>
        </nz-popconfirm>-->
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
